home *** CD-ROM | disk | FTP | other *** search
/ Aminet 35 / Aminet 35 (2000)(Schatztruhe)[!][Feb 2000].iso / Aminet / game / shoot / ADescentSrc.lha / descent / main / effects.c < prev    next >
C/C++ Source or Header  |  1998-03-03  |  7KB  |  257 lines

  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * $Source: /usr/CVS/descent/main/effects.c,v $
  15.  * $Revision: 1.1.1.1 $
  16.  * $Author: nobody $
  17.  * $Date: 1998/03/03 15:12:14 $
  18.  * 
  19.  * Special effects, such as rotating fans, electrical walls, and
  20.  * other cool animations. 
  21.  * 
  22.  * $Log: effects.c,v $
  23.  * Revision 1.1.1.1  1998/03/03 15:12:14  nobody
  24.  * reimport after crash from backup
  25.  *
  26.  * Revision 1.1.1.1  1998/02/13  20:20:46  hfrieden
  27.  * Initial Import
  28.  *
  29.  * Revision 2.0  1995/02/27  11:32:49  john
  30.  * New version 2.0, which has no anonymous unions, builds with
  31.  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  32.  * 
  33.  * Revision 1.21  1995/02/13  20:35:06  john
  34.  * Lintized
  35.  * 
  36.  * Revision 1.20  1994/12/10  16:44:50  matt
  37.  * Added debugging code to track down door that turns into rock
  38.  * 
  39.  * Revision 1.19  1994/12/06  16:27:14  matt
  40.  * Fixed horrible bug that was referencing segment -1
  41.  * 
  42.  * Revision 1.18  1994/12/02  23:20:51  matt
  43.  * Reset bitmaps possibly changed by crit clips
  44.  * 
  45.  * Revision 1.17  1994/11/14  14:00:19  matt
  46.  * Fixed stupid bug
  47.  * 
  48.  * Revision 1.16  1994/11/14  12:42:43  matt
  49.  * Allow holes in effects list
  50.  * 
  51.  * Revision 1.15  1994/11/08  21:11:52  matt
  52.  * Added functions to stop & start effects
  53.  * 
  54.  * Revision 1.14  1994/10/04  18:59:08  matt
  55.  * Exploding eclips now play eclip while exploding, then switch to static bm
  56.  * 
  57.  * Revision 1.13  1994/10/04  15:17:42  matt
  58.  * Took out references to unused constant
  59.  * 
  60.  * Revision 1.12  1994/09/29  11:00:01  matt
  61.  * Made eclips (wall animations) not frame-rate dependent (for now)
  62.  * 
  63.  * Revision 1.11  1994/09/25  00:40:24  matt
  64.  * Added the ability to make eclips (monitors, fans) which can be blown up
  65.  * 
  66.  * Revision 1.10  1994/08/14  23:15:14  matt
  67.  * Added animating bitmap hostages, and cleaned up vclips a bit
  68.  * 
  69.  * Revision 1.9  1994/08/05  15:56:04  matt
  70.  * Cleaned up effects system, and added alternate effects for after mine
  71.  * destruction.
  72.  * 
  73.  * Revision 1.8  1994/08/01  23:17:21  matt
  74.  * Add support for animating textures on robots
  75.  * 
  76.  * Revision 1.7  1994/05/23  15:10:46  yuan
  77.  * Make Eclips read directly... 
  78.  * No more need for $EFFECTS list.
  79.  * 
  80.  * Revision 1.6  1994/04/06  14:42:44  yuan
  81.  * Adding new powerups.
  82.  * 
  83.  * Revision 1.5  1994/03/15  16:31:54  yuan
  84.  * Cleaned up bm-loading code.
  85.  * (And structures)
  86.  * 
  87.  * Revision 1.4  1994/03/04  17:09:09  yuan
  88.  * New door stuff.
  89.  * 
  90.  * Revision 1.3  1994/01/11  11:18:50  yuan
  91.  * Fixed frame_count
  92.  * 
  93.  * Revision 1.2  1994/01/11  10:38:55  yuan
  94.  * Special effects new implementation
  95.  * 
  96.  * Revision 1.1  1994/01/10  09:45:29  yuan
  97.  * Initial revision
  98.  * 
  99.  * 
  100.  */
  101.  
  102.  
  103. #pragma off (unreferenced)
  104. static char rcsid[] = "$Id: effects.c,v 1.1.1.1 1998/03/03 15:12:14 nobody Exp $";
  105. #pragma on (unreferenced)
  106.  
  107. #include <stdio.h>
  108. #include <stdlib.h>
  109. #include <stdarg.h>
  110. #include <string.h>
  111.  
  112. #include "gr.h"
  113. #include "inferno.h"
  114. #include "game.h"
  115. #include "vclip.h"
  116. #include "effects.h"
  117. #include "bm.h"
  118. #include "mono.h"
  119. #include "mem.h"
  120. #include "textures.h"
  121. #include "fuelcen.h"
  122. #include "error.h"
  123.  
  124. int Num_effects;
  125. eclip Effects[MAX_EFFECTS];
  126.  
  127. void init_special_effects() 
  128. {
  129.     int i;
  130.  
  131.     for (i=0;i<Num_effects;i++)
  132.         Effects[i].time_left = Effects[i].vc.frame_time;
  133. }
  134.  
  135. void reset_special_effects()
  136. {
  137.     int i;
  138.  
  139.     for (i=0;i<Num_effects;i++) {
  140.         Effects[i].segnum = -1;                    //clear any active one-shots
  141.         Effects[i].flags &= ~(EF_STOPPED|EF_ONE_SHOT);        //restart any stopped effects
  142.  
  143.         //reset bitmap, which could have been changed by a crit_clip
  144.         if (Effects[i].changing_wall_texture != -1)
  145.             Textures[Effects[i].changing_wall_texture] = Effects[i].vc.frames[Effects[i].frame_count];
  146.  
  147.         if (Effects[i].changing_object_texture != -1)
  148.             ObjBitmaps[Effects[i].changing_object_texture] = Effects[i].vc.frames[Effects[i].frame_count];
  149.  
  150.     }
  151. }
  152.  
  153. void do_special_effects()
  154. {
  155.     int i;
  156.     eclip *ec;
  157.  
  158.     for (i=0,ec=Effects;i<Num_effects;i++,ec++) {
  159.  
  160.         if ((Effects[i].changing_wall_texture == -1) && (Effects[i].changing_object_texture==-1) )
  161.             continue;
  162.  
  163.         if (ec->flags & EF_STOPPED)
  164.             continue;
  165.  
  166.         ec->time_left -= FrameTime;
  167.  
  168.         while (ec->time_left < 0) {
  169.  
  170.             ec->time_left += ec->vc.frame_time;
  171.             
  172.             ec->frame_count++;
  173.             if (ec->frame_count >= ec->vc.num_frames) {
  174.                 if (ec->flags & EF_ONE_SHOT) {
  175.                     Assert(ec->segnum!=-1);
  176.                     Assert(ec->sidenum>=0 && ec->sidenum<6);
  177.                     Assert(ec->dest_bm_num!=0 && Segments[ec->segnum].sides[ec->sidenum].tmap_num2!=0);
  178.                     Segments[ec->segnum].sides[ec->sidenum].tmap_num2 = ec->dest_bm_num | (Segments[ec->segnum].sides[ec->sidenum].tmap_num2&0xc000);        //replace with destoyed
  179.                     ec->flags &= ~EF_ONE_SHOT;
  180.                     ec->segnum = -1;        //done with this
  181.                 }
  182.  
  183.                 ec->frame_count = 0;
  184.             }
  185.         }
  186.  
  187.         if (ec->flags & EF_CRITICAL)
  188.             continue;
  189.  
  190.         if (ec->crit_clip!=-1 && Fuelcen_control_center_destroyed) {
  191.             int n = ec->crit_clip;
  192.  
  193.             //*ec->bm_ptr = &GameBitmaps[Effects[n].vc.frames[Effects[n].frame_count].index];
  194.             if (ec->changing_wall_texture != -1)
  195.                 Textures[ec->changing_wall_texture] = Effects[n].vc.frames[Effects[n].frame_count];
  196.  
  197.             if (ec->changing_object_texture != -1)
  198.                 ObjBitmaps[ec->changing_object_texture] = Effects[n].vc.frames[Effects[n].frame_count];
  199.  
  200.         }
  201.         else    {
  202.             // *ec->bm_ptr = &GameBitmaps[ec->vc.frames[ec->frame_count].index];
  203.             if (ec->changing_wall_texture != -1)
  204.                 Textures[ec->changing_wall_texture] = ec->vc.frames[ec->frame_count];
  205.     
  206.             if (ec->changing_object_texture != -1)
  207.                 ObjBitmaps[ec->changing_object_texture] = ec->vc.frames[ec->frame_count];
  208.         }
  209.  
  210.     }
  211. }
  212.  
  213. void restore_effect_bitmap_icons()
  214. {
  215.     int i;
  216.     
  217.     for (i=0;i<Num_effects;i++)
  218.         if (! (Effects[i].flags & EF_CRITICAL))    {
  219.             if (Effects[i].changing_wall_texture != -1)
  220.                 Textures[Effects[i].changing_wall_texture] = Effects[i].vc.frames[0];
  221.     
  222.             if (Effects[i].changing_object_texture != -1)
  223.                 ObjBitmaps[Effects[i].changing_object_texture] = Effects[i].vc.frames[0];
  224.         }
  225.             //if (Effects[i].bm_ptr != -1)
  226.             //    *Effects[i].bm_ptr = &GameBitmaps[Effects[i].vc.frames[0].index];
  227. }
  228.  
  229. //stop an effect from animating.  Show first frame.
  230. void stop_effect(int effect_num)
  231. {
  232.     eclip *ec = &Effects[effect_num];
  233.     
  234.     //Assert(ec->bm_ptr != -1);
  235.  
  236.     ec->flags |= EF_STOPPED;
  237.  
  238.     ec->frame_count = 0;
  239.     //*ec->bm_ptr = &GameBitmaps[ec->vc.frames[0].index];
  240.  
  241.     if (ec->changing_wall_texture != -1)
  242.         Textures[ec->changing_wall_texture] = ec->vc.frames[0];
  243.     
  244.     if (ec->changing_object_texture != -1)
  245.         ObjBitmaps[ec->changing_object_texture] = ec->vc.frames[0];
  246.  
  247. }
  248.  
  249. //restart a stopped effect
  250. void restart_effect(int effect_num)
  251. {
  252.     Effects[effect_num].flags &= ~EF_STOPPED;
  253.  
  254.     //Assert(Effects[effect_num].bm_ptr != -1);
  255. }
  256.  
  257.